jQuery(function($) {
    $.isAjaxLance = 1;
    
  
    
    $('a[role="addNewLance"]').off('click').on('click', setLance);
    function setLance(ev) {
        ev.preventDefault();
        var obj = this;
        var idLe = $(this).attr('data-le-id'), idLt = $(this).attr('data-lt-id'),
                idAt = $(this).attr('data-at-id'),
                date_ativo_finish = $(this).attr('data-lance-lote'),
                minutes_sec = minutes * 60,
                upd = onTicker['data-' + idLt] < minutes_sec ? 'yes' : 'no',
                multiply = $('.btn-lance-option.active').attr('data-multiply') || 1;



        if (multiply == '*') {
            multiply = OptionMultiply;
        }
        $.onTickerleilao.tickers_stamp[idLt] = false;
        if (upd === 'yes') {
            var $mktime = mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y'));

            $.onTickerleilao.tickers_stamp[idLt] = date('Y-m-d H:i:s', $mktime);
        }

        if ($.isAjaxLance === 1) {
            $.ajax({
                url: url_site + 'home/addLanceUser',
                type: 'post',
                dataType: 'json',
                beforeSend: function() {
                    $('<div class="grid-loading pull-right" style="margin-top:10px;"></div>').insertAfter(obj);
                    $('.grid-loading').show();
                    $.isAjaxLance = 0;
                },
                data: {
                    leilao_id: idLe,
                    lote_id: idLt,
                    ativo_id: idAt,
                    m: multiply,
                    updtime: upd,
                    seconds: minutes_sec,
                    end: date_ativo_finish
                },
                success: function(data) {

                    $('.grid-loading').remove();
                    if (data.error) {
                        alert(data.message);
                    } else {


                    }
                },
                complete: function() {
                    $.isAjaxLance = 1;
                }
            });
        }
    }
});